﻿<%--
Copyright (C) 2004-2006  Autodesk, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of version 2.1 of the GNU Lesser
General Public License as published by the Free Software Foundation.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
--%>

<%@ Page language="c#" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="OSGeo.MapGuide" %>
<!-- #Include File="../utilityfunctions.aspx" -->
<!-- #Include File="findlocationfunctions.aspx" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<html>

<head>
    <title>Find Address Task</title>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <link rel="stylesheet" href="../../../styles/gt.css" type="text/css" />
      <link rel="stylesheet" href="../../styles/viewer.css" type="text/css" />
    <script type="text/javascript" language="javascript" src="js/ZoomCoord2.js"></script>
    <script language="javascript" type="text/javascript">

       
        function InitDocument()
        {
            dblKanam = parseFloat(document.getElementById("kanam").value);
            
          
            locationForm.LonInput.value=parent.parent.parent.Reqlon;
            locationForm.LatInput.value=parent.parent.parent.Reqlat;
	    if(locationForm.LonInput.value=='' || locationForm.LonInput.value=='undefined'){
	    	locationForm.LonInput.value='';
		locationForm.LatInput.value='';
	    }else
        {
	        locationForm.submit();

}
        }

      function DigitizePoint() {
          locationForm.LonInput.value='';
          locationForm.LatInput.value='';
          parent.parent.mapFrame.DigitizePoint(OnPointDigitized);
      }
      function OnPointDigitized(point) {
          locationForm.LonInput.value=point.X;
          locationForm.LatInput.value=point.Y;
      }

    </script>
</head>

<body onload="InitDocument()" dir="rtl" >

<%
String mgSessionId = GetRequestParameters()["SESSION"];
String mgMap = GetRequestParameters()["MAPNAME"];
bool showPreviousResults = false;
MgSiteConnection siteConnection = null;
String dblKanam;
try
{
    // Initialize the web-extensions and connect to the Site using
    // the session identifier stored

    InitializeWebTier();
   
    MgUserInformation userInfo = new MgUserInformation(mgSessionId);
    siteConnection = new MgSiteConnection();
    siteConnection.Open(userInfo);

    // Create a ReserviceService object and use it to open the Map
    // object from the sessions repository. Use the Map object to
    // determine if the "AddressMarker" layer is visible.

    MgResourceService resourceService = siteConnection.CreateService(MgServiceType.ResourceService) as MgResourceService;
    MgMap map = new MgMap();
    map.Open(resourceService, mgMap);
    MgLayer locationLayer = GetLayerByName(map, "LocationMarker");

    if (locationLayer != null)
    {
        showPreviousResults = locationLayer.GetVisible();
    }
}
catch (MgException mge)
{
   // Response.Write(mge.GetExceptionMessage());
    //Response.Write(mge.GetDetails());
}
%>

<form id="locationForm" action="findlocation.aspx" method="get" target="_self">
    <input name="SESSION" type="hidden" value="<%= mgSessionId %>" />
    <input id="map" name="map" type="hidden" value="<%=mgMap%>" />
    <table border="0" cellspacing="0" cellpadding="0" width="100%" dir="rtl" style="height:28px">
      <tr><td class="clsHeaderLight">התמקדות לפי קואורדינאטות</td></tr>
      <tr><td class="clsHr" ></td></tr>
      <tr>
       <td><input  class="clsShortButton"  id="Button1" type="button" value="בחר מהמפה" onclick="DigitizePoint()" style="width:60px"/></td> 
       </tr>
    </table>
    <table border="0" cellpadding="5" dir="rtl">
      <tr>
        <td class="clsFieldHeader" width="80px">סוג הרשת :</td>
        <td align="right" class="MeasureData" >
            <select id=reshet dir=rtl style="width:130px">
                <!--<option value="1">רשת ישראל הישנה</option>-->
                <option value="2" selected>רשת ישראל החדשה</option>
               <!-- <option value="3">רשת UTM</option>
                <option value="4">רשת WGS84</option>-->
            </select>
        </td>
      </tr>
      <tr>
        <td class="clsFieldHeader">Y/Lat/North :</td>
        <td align="right" class="MeasureData">
            <!--<input id=Ycoord style="width:120px" dir=ltr />-->
            <input   id="Ycoord" maxlength="10" class="Ctrl" name="LonInput" style="width:120px" value="" />
        </td>
      </tr>
      <tr>
        <td class="clsFieldHeader">X/Lon/East:</td>
        <td align="right" class="MeasureData">
            <!--<input id=Xcoord style="width:120px" dir=ltr /> -->
            <input maxlength="10" class="Ctrl" id="Xcoord" name="LatInput" style="width:120px" value="" />
        </td>
      </tr>
      <tr>
        <td class="clsFieldHeader">קנה-מידה :</td>
        <td align="right" class="MeasureData" >
            <input id="kanam"   name="kanam" style="width:100px" dir=ltr value="10000" />:1
        </td>
      </tr>
       <tr >
        <td colspan=2 class="clsFieldHeader">שמור מיקום : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input type=checkbox id="SaveNaaz" value=0 /></td>
      </tr>
      <tr>
        <td colspan="2">
        
        <table>
        <tr>
        <td>  <input class="clsShortButton" type="button" value="נקה"  onclick="Clear()" style="width:60px"/></td>
        <td> <input class="clsShortButton" type="button" value="בצע" style="width:60px" onclick="Zoom()" /></td>
       <!-- <td>   
         <script language="javascript"  type="text/javascript">
             /*if (ClearResults.MAP.value == "") {
                 try { ClearResults.MAP.value = locationForm.map.value; } catch (e) { }
             }*/
    function clearmap()
    {
   /*   parent.Refresh();*/
     this.location.href = "findlocationmain.aspx?SESSION=<%= mgSessionId %>&map=<%= mgMap %>";
      }

    </script>
       <form id="ClearResults" action="clearlocationresults.aspx" method="get" target="scriptFrame">
   <input type="hidden" name="SESSION" value="<%= mgSessionId %>" />
    <input type="hidden" name="map" value="<%=mgMap%>" />
    <input type="button" class="clsShortButton" value="נקה" onclick="clearmap()" />
   </form>*/
  
        <!--<input class="clsShortButton" type="button" value="סגור"  onclick="CloseForm()" style="width:60px"/></td>
        -->
       
        </tr>
        </table>
   
            
        <!--<input class="clsShortButton" type="button" value="התמקד"  onclick="Zoom()" />-->
            &nbsp;&nbsp;
         
            
        </td>
      </tr>
     <!-- <tr height=20px>
        <td colspan=2></td>
      </tr>
      <tr >
        <td colspan=2 class="clsHeaderLight">קואורדינאטות מותמרות</td>
      </tr>
      <tr>
        <td class="clsFieldHeader">קואורד' Y :</td>
        <td align="right" class="MeasureData">
            <input id=txtResY style="width:120px" dir=ltr />
        </td>
      </tr>
    
      <tr>
        <td class="clsFieldHeader">קואורד' X:</td>
        <td align="right" class="MeasureData">
            <input id=txtResX style="width:120px" dir=ltr />
        </td>
      </tr>
        -->
    </table>  
  <!--  <table dir="rtl" class="RegText" border="0" cellspacing="0" width="100%">
        <tr><td class="Title">&nbsp;איתור מיקום<hr></td></tr>
        <tr><td class="SubTitle">התמקד לנקודת ציון במפה</td></tr>
        <tr><td>מיקום:</td></tr>
  
        <tr><td><br /></td></tr>
        <tr><td><br />או הקלד באופן ידני</td></tr>
        <tr><td><br /><strong>Lat Lon</strong></td></tr>
        <tr>
            <td class="RegText">
                <!--X: <input maxlength="10" class="Ctrl" name="LonInput" style="width: 75%" value="" /><br/>
              <!--  Y: <input maxlength="10" class="Ctrl" name="LatInput" style="width: 75%" value="" />
		
            </td>
        </tr>
        <tr><td class="Title"><hr /></td></tr>
        <tr>
            <td>
           
            </td>
        </tr>

    </table>-->
</form>

<%
// If there are previous results, display them as hyperlinks and emit
// a second form with a Clear Results button.

if (showPreviousResults)
{
    MgFeatureService featureService = siteConnection.CreateService(MgServiceType.FeatureService) as MgFeatureService;
    MgResourceIdentifier addressMarkerDataResId = new MgResourceIdentifier("Session:" + mgSessionId + "//LocationMarker.FeatureSource");
    //MgResourceIdentifier addressMarkerDataResId = new MgResourceIdentifier("Library://findLocation/" + mgSessionId + "/LocationMarker.FeatureSource");

    EmitLocationResults(featureService, addressMarkerDataResId, mgSessionId, Response);
}

%>



</body>
</html>
